// 引入koa模块，路由模块，post模块, controller middleware
const Koa = require('Koa')
const router = require('koa-router')()
const bodyParser = require('koa-bodyparser')
const app = new Koa()
const controller = require('./controller')
app.use(bodyParser())

app.use(async(ctx, next) => {
    console.log(`Process ${ctx.request.method} ${ctx.request.url}...`)
    await next()
})

app.use(router.routes())

const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/M&t', {useNewUrlParser: true})

app.use(controller())

app.listen(3000)
console.log('app started at port 3000...')
